// 检测类型是否有特定方法的SFINAE技术
template <typename T>
class HasNormalize
{
    template <typename U>
    static auto test(int) -> decltype(std::declval<U>().normalize(), std::true_type{});

    template <typename>
    static std::false_type test(...);

public:
    static constexpr bool value = decltype(test<T>(0))::value;
};

// 根据类型特性选择算法
template <typename PointT>
typename std::enable_if<HasNormalize<PointT>::value, void>::type
process_points(std::vector<PointT> &points)
{
    std::cout << "Processing points with normalization" << std::endl;
    for (auto &p : points)
    {
        p.normalize(); // 直接调用点的normalize方法
    }
}

template <typename PointT>
typename std::enable_if<!HasNormalize<PointT>::value, void>::type
process_points(std::vector<PointT> &points)
{
    std::cout << "Processing points without normalization" << std::endl;
    // 手动实现归一化
    for (auto &p : points)
    {
        float norm = std::sqrt(p.x * p.x + p.y * p.y + p.z * p.z);
        if (norm > 0)
        {
            p.x /= norm;
            p.y /= norm;
            p.z /= norm;
        }
    }
}